< previous page page_79 next page >

Page 79
"It's the latest craze." She shook her head. "Now they've all discovered multimedia, so they want their computers to do everything. I'm all set up to use my modem to call out, but to do this thing right I really need to be able to add that functionality to a program I'm working on. Any ideas?"
I thought a moment. "How about RAS?"
"Yeah, I thought about that. But the Remote Access Service API is nasty stuff. I'm having trouble making it work. Take a look at this onethe RasEnumEntries API. I'm trying to get a list of the phone entries set up on the system."
I sat down next to her and looked at the Win32 SDK screen she had showing:
DWORD RasEnumEntries (
    LPTSTR reserved, // reserved, must be NULL
    LPTSTR lpszPhonebook, // pointer to full path and file name of
                           // phone book file
    LPRASENTRYNAME lprasentryname, // buffer to receive phone
                                      // book entries
    LPDWORD lpcb, // size in bytes of buffer
    LPDWORD lpcEntries // number of entries written to buffer
   );
"Doesn't look too bad to me. The reserved parameter is NULL, so we'll probably make it ByVal As Long and pass 0. I see from the description below that the lpszPhonebook can also be NULL to use the default phone book. Hmm . . . now it gets tricky."
"That's right," she replied grimly. "The lprasentryname parameter is a pointer to an array of RASENTRYNAME structures. The structure looks like this:
typedef struct _RASENTRYNAME {
    DWORD dwSize;
    TCHAR szEntryName[RAS_MaxEntryName + 1];
}RASENTRYNAME;
where MaxEntryName is 256. We can probably pull the usual array trick and pass the first element in an array, but how big an array do we need?"
"Easy," I replied. "The lpcb parameter is a Long variable that we initialize to the size of the bufferthat is, the number of bytes in the lprasentryname array. According to the documentation, if the array isn't long enough, the function will return error 603 indicating that a larger buffer is needed. The lpcEntries parameter is a Long variable that will be loaded with the number of entries in the array."
She reviewed the comments in the documentation. "Don't forget, the dwSize parameter in the lprasentryname array structures must be set to the correct array size."

 
< previous page page_79 next page >